/**
 * Created by Administrator on 2017/2/12.
 */
import { Component,OnInit,Input,ViewChild,Output,EventEmitter}    from '@angular/core';
import { reseditService }                 from './resedit.serve';
import {FileUploader}                      from "ng2-file-upload";

@Component({
  moduleId: module.id,
  selector: 'my-resedit',
  templateUrl: 'resedit.html',
  providers:[ reseditService ]
})
export class ReseditComponent implements OnInit{
  public uploader:FileUploader = new FileUploader({
    url: "http://api.pinwu.net/upload/uploadfile",
    method: "POST",
    itemAlias: "uploadedfile"
  });

  @Input() inputData;
  @Output() outputEvent:EventEmitter<string>=new EventEmitter();
  @Output() inputDataChange=new EventEmitter();
  constructor(
    private ReseditService:reseditService
  ){}
  private restue='';
  private restue1='';
  private restue2='';
  private restue3='';
  @ViewChild('specail') public Specail;
  private parentRouteId: number;
  selectedFileOnChanged(event:any) {
    console.log(event.target.value);
    this.uploadFile();
  }
  uploadFile() {
    // 上传
    this.uploader.queue[0].onSuccess = function (response, status, headers) {
      // 上传文件成功
      if (status == 200) {
        // 上传文件后获取服务器返回的数据
        let tempRes = JSON.parse(response);
      } else {
        // 上传文件后获取服务器返回的数据错误
        alert("");
      }
    };
    this.uploader.queue[0].upload(); // 开始上传
  }
   checkvalu=[];
  private k='';
  // public getbox(){
  //  let obj = window['document'].getElementsByClassName("cbGntx");
  //  let k=this.k;
  //   for(k in obj){
  //       if(obj[k].checked){
  //         this.checkvalu.push(obj[k].value)
  //       }
  //   }
  // }

  // public getbox(){
  //   let Specail=this.Specail;
  //   let k=this.k;
  //    for(k in Specail){
  //      if(Specail[k].checked){
  //       this.checkvalu.push(Specail[k].value)
  //      }
  //    }
  //    console.log(Specail[k].checked);
  //    alert(this.checkvalu)
  // }
   ngOnInit(){
    this.ReseditService.getmateril()
      .subscribe(
        res=>{this.restue=res['attr1'];
          this.restue1=res['attr2'];
          this.restue2=res['attr3'];
          this.restue3=res['attr4'];
        console.log(this.restue)
        }
      )
   }

}
